<!--_meta 作为公共模版分离出去-->
{include file="common/_meta" /}
<!--/meta 作为公共模版分离出去-->
<title>添加商品</title>
</head>
<body>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>
		商品管理
		<span class="c-gray en">&gt;</span>
		添加商品
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
		 title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<style type="text/css">
		input,
		label {
			vertical-align: middle;
		}
	</style>
	<div class="page-container">
		<form action="" method="post" class="form form-horizontal" id="form-article-add" enctype="multipart/form-data">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">
					<span class="c-red">*</span>
					商品名称：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" id="goods_name" name="goods_name" placeholder="输出名称长度介于 3 和 200 之间" value="" class="input-text">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">分类栏目：</label>
				<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
						<select name="cate_id" id="cate" class="select">
							<option value=0>选择栏目</option>
							{volist name="cate" id="vo"}
							<option value="{$vo.id}">{$vo.name}</option>
							{/volist}
						</select>
					</span> </div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>产品首页主图：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<a href="javascript:void();" class="btn btn-primary radius"><i class="icon Hui-iconfont">&#xe642;</i> 浏览文件</a>
					<input type="file" class="input-file" onchange='onpic(this)' name="goods_img" value="" accept='image/*'	 style="font-size: 20px;left:0;" />
					<span class="sp"></span>
					<span style="color: red;margin-left: 20px;">注意：请上传图片比例为1:1。防止变形！</span>
				</div>
			</div>
			
			
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">
					是否上架：</label>
				<div class="formControls col-xs-9 col-sm-9">
					<div class="switch" data-on-label="开" data-off-label="关">
						<input type="checkbox" checked="checked" name="isopen" />
					</div>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>市场价格：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="markte_price" id="" placeholder="请输入市场价格" value="" class="input-text" style="width:30%">
					元</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>本店价格：</label>
				<div class="formControls col-xs-4 col-sm-4">
					<input type="number" name="money" id="" placeholder="请输入现金价格" value="" class="input-text" style="width:80%">
					元</div>
			
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">返现：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="fen_money" id="" placeholder="请输入市场价格" value="0" class="input-text" style="width:30%">
					元</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>库存：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="kucun_num" id="" placeholder="请输入库存" value="100000" class="input-text" style="width:30%">
					默认库存为100000</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>邮费：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="postage" id="" placeholder="请输入邮费" value="0" class="input-text" style="width:30%">
					元</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>已售卖数量：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="sales_num" id="" placeholder="已售卖数量" value="<?php echo mt_rand(1000,5000); ?>" class="input-text" style="width:30%">
					随机显示 1000-5000 之间</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>产品浏览数：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="liu_num" id="" placeholder="产品浏览数" value="<?php echo mt_rand(1000,10000); ?>" class="input-text" style="width:30%">
					随机显示 1000-10000 之间</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">添加属性：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" name="attr_title" id="" placeholder="输入属性标题" value="" class="input-text" style="width:30%">
					<input type="text" name="attr_value" id="" placeholder="输入属性可能值，用逗号隔开" value="" class="input-text" style="width:60%;margin-left: 5%;">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">抓取京东：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text"  id="jingdong" placeholder="京东地址"  class="input-text" style="width:90%">
					<button type="button" class="btn btn-success radius" onclick="zhua()">抓取</button>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>详细内容：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<script id="goods_desc" name="goods_desc" type="text/plain" style="width:100%;height:450px;"></script>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
					<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i>
						保存</button>
				</div>
			</div>
		</form>
	</div>

	<!--_footer 作为公共模版分离出去-->
	{include file="common/_footer" /}
	<!--/_footer /作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<style type="text/css">
		.li123 {
			line-height: 30px;
			background: burlywood;
			display: inline-block;
			vertical-align: middle;
			padding: 0 8px;
		}
	</style>

	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/ueditor/ueditor.all.min.js"> </script>
	<script type="text/javascript" src="__MANAGE__lib/ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript">
		$(function() {
			$('.skin-minimal input').iCheck({
				checkboxClass: 'icheckbox-blue',
				radioClass: 'iradio-blue',
				increaseArea: '20%'
			});
			$("#tab-system").Huitab({
				index: 0
			});
			$("#form-article-add").validate({
				rules: {
					goods_name: {
						required: true,
						rangelength: [3, 200]
					},
					cate_id: {
						required: true,
					},
					factoryid: {
						required: true,
					},
					markte_price: {
						required: true,
						number: true
					},
					money: {
						required: true,
						number: true
					},
					goods_desc: {
						required: true,
					},
					goods_img:{
						required: true,
					}
				}
			});
			UE.getEditor('goods_desc');
		});
		function onduo(e){
			let fs=$(e)[0].files
			let html= '';
			
			for (let s of fs) {
				html+='<div style="width: 14%;padding: 15px;"><img style="width: 100%;" src="'+window.URL.createObjectURL(s)+'" alt=""></div>'
			}
			$('#tu').html(html)
		}

		function onpic(e) {
			$(e).parent().find('.sp').html('您已经选择图片：' +$(e)[0].files[0].name).addClass('li123');
		}
		function zhua(){
			let url=$('#jingdong').val()

			$.post(
				"{:url('goods/ajax')}",
			{
				type:'goods_zhua',
				url:url
			},
			function(res){
				if(res.code==1){
					var ue = UE.getEditor('goods_desc');
					let html=''
					for (let s of res.data) {
						html+='<img src="'+s+'" alt="">'
					}
					ue.setContent(html);
				}else{
					layer.msg(res.msg,{icon: 5,time:1000});
				}
			    
			});	
		}

	</script>
	<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
